<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>京东轮播图动态生成小圆点</title>
    <style>
        *{
            margin:0;
            padding:0;
        }

        ul{
            list-style: none;
        }


        .slider {
            width: 730px;
            height: 454px;
            margin: 100px auto;
            overflow: hidden;
            position: relative;
        }

        .point {
            position: absolute;
            bottom: 15px;
            left: 50%;
        }

        .point span {
            display: inline-block;
            margin-right: 5px;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background-color: #3e3e3e;
            color: white;
            line-height: 20px;
            text-align: center;
            cursor: pointer;
            font-family: 'Arial', "Microsoft YaHei UI";
        }
        
        .point span.current {
            background-color: #b61d1d;
        }
    </style>

    <script>
        window.onload = function () {
            var lis = document.getElementsByTagName("li");
            var point = document.getElementsByClassName("point")[0];
            for (var i = 0; i < lis.length; i++) {
                var span = document.createElement("span");
                span.innerHTML = i+1;
                point.appendChild(span);
            }
            point.children[0].className = "current";
            console.log(point.offsetWidth);
            point.style.marginLeft = -point.offsetWidth / 2 + "px";
        }
    </script>
</head>
<body>
<div class="slider">
    <div class="photo">
        <ul>
            <li><img src="images/11.jpg" alt=""></li>
            <li><img src="images/22.jpg" alt=""></li>
            <li><img src="images/33.jpg" alt=""></li>
            <li><img src="images/44.jpg" alt=""></li>
            <li><img src="images/55.jpg" alt=""></li>
            <li><img src="images/66.jpg" alt=""></li>
        </ul>
    </div>

    <div class="point">
        <!--<span>1</span>
        <span>2</span>
        <span>3</span>
        <span>4</span>
        <span>5</span>
        <span>6</span>-->
    </div>
</div>
</body>
</html>